Jupyter¶

You should build a data analytics project in a Jupyter notebook. In particular, you should do the following:

  • Load the Gapminder dataset using the below code cell.
  • Extract and visualize interesting insights about countries using Pandas and Plotly.
  • Structure, document, and decorate your notebook using Markdown.
In [1]:
import pandas as pd
import plotly
import plotly.express as px
import plotly.graph_objects as go

df = px.data.gapminder()
df.head()
Out[1]:
country continent year lifeExp pop gdpPercap iso_alpha iso_num
0 Afghanistan Asia 1952 28.801 8425333 779.445314 AFG 4
1 Afghanistan Asia 1957 30.332 9240934 820.853030 AFG 4
2 Afghanistan Asia 1962 31.997 10267083 853.100710 AFG 4
3 Afghanistan Asia 1967 34.020 11537966 836.197138 AFG 4
4 Afghanistan Asia 1972 36.088 13079460 739.981106 AFG 4
In [4]:
canada = df[df["country"]=="Canada"]
canada.head()
Out[4]:
country continent year lifeExp pop gdpPercap iso_alpha iso_num
240 Canada Americas 1952 68.75 14785584 11367.16112 CAN 124
241 Canada Americas 1957 69.96 17010154 12489.95006 CAN 124
242 Canada Americas 1962 71.30 18985849 13462.48555 CAN 124
243 Canada Americas 1967 72.13 20819767 16076.58803 CAN 124
244 Canada Americas 1972 72.88 22284500 18970.57086 CAN 124
In [1]:
import plotly.express as px

df = px.data.gapminder().query("country=='Canada'")
fig = px.line(df, x="year", y="pop", title='Population in Canada')
fig.show()
In [2]:
import plotly.express as px

df = px.data.gapminder().query("continent=='Europe'")
fig = px.line(df, x="year", y="pop", color='country')
fig.show()
In [3]:
import plotly.express as px
df = px.data.gapminder()

fig = px.scatter(df.query("year==2007"), x="gdpPercap", y="lifeExp",
	         size="pop", color="continent",
                 hover_name="country", log_x=True, size_max=60)
fig.show()
In [31]:
import plotly.express as px
df = px.data.gapminder().query("year == 2007").query("continent == 'Europe'")
df.loc[df['pop'] < 2.e6, 'country'] = 'Other countries' # Represent only large countries
fig = px.pie(df, values='pop', names='country', title='Population of European continent')
fig.show()
In [35]:
import plotly.express as px
# This dataframe has 244 lines, but 4 distinct values for `day`
df = px.data.gapminder().query("continent == 'Asia'").query("year==2007")
fig = px.pie(df, values='pop', names='country', title='Population of Asia in 2007')
fig.show()
In [41]:
import plotly.express as px
df = px.data.gapminder().query("continent == 'Asia'")
fig = px.area(df, x="year", y="pop")
fig.show()

akerkr.nur@bk.ru - my email

https://www.youtube.com - my favourite website

My favorite website is YouTube "The best website"

In [ ]: